var httpRequestModule = (function() {
    'use strict';

    function executeHttpRequest(url, type, data, headers) {
        var $deferred = jQuery.Deferred();

        $.ajax({
            url: url,
            type: type,
            data: JSON.stringify(data),
            headers: headers,
            contentType: 'application/json',
            timeout: 5000,
            success: function(data) {
                $deferred.resolve(data);
            },
            error: function(error) {
                $deferred.reject(error);
            }
        });

        return $deferred.promise();
    }

    function getJSON(url) {
        return executeHttpRequest(url, 'GET');
    }

    function postJSON(url, data) {
        return executeHttpRequest(url, 'POST', data);
    }

    return {
        getJSON: getJSON,
        postJSON: postJSON
    };
}());